import { http } from "@/utils/http";
import type { PaginationResponse } from "types";
import type { Article, ArticleStatsItem } from "types/article";

export const getArticlePagination = (params: {
  page: number;
  page_size: number;
  kw?: string;
}) => {
  return http.request<PaginationResponse<Article>>("get", "/article", {
    params
  });
};

export const createArticle = (data: object) => {
  return http.request<Article>("post", "/article", {
    data
  });
};

export const updateArticle = (data: object) => {
  return http.request("put", "/article", {
    data
  });
};

export const deleteArticle = (id: number) => {
  return http.request("delete", "/article/" + id);
};

export const getArticleStats = () => {
  return http.request<ArticleStatsItem[]>("get", "/article/stats");
};
